@model ResultPartialModel

@{
  Layout = "";
}

@{
  //Model.pageCount = 2;
  Model.Init();
}

@functions {
  String decodeTry(String str)
  {
    return PageText.decodeTry(str);
  }
}

<div id='@Html.Raw( "ldiv" + @Model.IdToString() )'>
  @{
    var pages = Model.pages;
    //var isFirstLoad = Model.isFirstLoad;
    //var pageCount = Model.pageCount;

    foreach (var p in pages)
    {
      if (p.priority == 0)
      {
        continue;
      }
      int minSize = 200;
      if (p.keyWord is KeyWordE)
      {
        minSize = 300;
      }
      bool isdesc = p.priority >= PageText.descriptionPriority;
      String content = isdesc ? p.text
      : IndexPage.getDesc(p.text, p.keyWord, minSize - 20);

      if (content.Length < minSize && p.page != null)
      {
        content += "... " + p.page.getRandomContent(minSize);
      }
      String sp = p.keywords.IndexOf(',') > 0 ? "," : " ";
      String[] keywords = p.keywords.Split(sp);


      <div hurl="@p.textOrder" style="display:none;">
        <div class="spartcss" dir="auto"><a class="stext" target="_blank" href="@p.url">@p.title</a></div>

        <div class="stext" dir="auto"> @content </div>
        @{
          var css = isdesc ? "gt" : "gtt";
        }
        <div class="@css">
          [@p.dbOrder-@p.textOrder]
          @if (p.isAndSearch)
          {
          }
          else
          {
            <text>*</text>
          }

          @decodeTry(p.url)

          @p.createTime

          @if (keywords.Length > 0)
          {
            @: <br>
          }
          @foreach (var tkw in keywords)
          {
            var kw = tkw.Trim();
            if (kw == null || kw.Length < 1) { continue; }
            if (kw.IndexOf(" ") > 0)
            {
              //kw = "\"" + kw + "\"";
            }
            <a href="About?q=@Html.Raw(System.Net.WebUtility.UrlEncode(kw))" class="@css kw stext_s"> &nbsp; @kw &nbsp; </a>
            <text> &nbsp; </text>
          }
        </div>
        <br>
      </div>
    }
  }
</div>

<div class="ui teal message" id='@Html.Raw("s" + @Model.IdToString())' dir="auto">
  @{
    String tcontent = (DateTime.Now - Model.begin).TotalSeconds + "s, "
      + "MEM:" + (System.GC.GetTotalMemory(false) / 1024 / 1024) + "MB ";

    @: @Model.Query, TIME: @tcontent,
    <a href="#btnsearch"><strong>
        @if (!@Model.IsEnd())
        {
          @:"Loading"

        }
        else
        {
          @:"END"

        }
      </strong></a>
  }
</div>
<br>
<script>
  setTimeout(function () {
    highlight('@Html.Raw( "ldiv" + @Model.IdToString() )');
    hideMultiText('@Html.Raw( "ldiv" + @Model.IdToString() )');
  @if (!@Model.IsEnd())
  {
    //startId is a big number, in javascript, have to write big number as a 'String'
    @:onscroll_loaddiv('@Html.Raw( "s" + @Model.IdToString() )', '@Model.IdToString()');

  }
    }, 100);
  extitle = "@Html.Raw(@Model.ToKeyWordString())";
</script>